package cc.rengu.redp.bizimpl.upmp.service.impl;

import cc.rengu.igas.bomp.facade.BompMchntManageService;
import cc.rengu.igas.bomp.facade.BompMchntPublicDealService;
import cc.rengu.igas.bomp.facade.bean.SysParamBean;
import cc.rengu.igas.bomp.facade.request.ParamQueryRequest;
import cc.rengu.igas.bomp.facade.response.ParamQueryResponse;
import cc.rengu.igas.bomp.facade.result.Result;
import cc.rengu.redp.bizimpl.enums.*;
import cc.rengu.redp.bizimpl.upmp.common.BusinessContainer;
import cc.rengu.redp.bizimpl.upmp.domain.DirectMchntBaseInfo;
import cc.rengu.redp.bizimpl.upmp.dao.DirectMchntBaseInfoMapper;
import cc.rengu.redp.bizimpl.upmp.domain.UpmpBMchntImageInfo;
import cc.rengu.redp.bizimpl.upmp.domain.UpmpOrganization;
import cc.rengu.redp.bizimpl.upmp.domain.UpmpPrivilegeCheck;
import cc.rengu.redp.bizimpl.upmp.service.*;
import cc.rengu.redp.bizimpl.upmp.vo.ImageInfoVO;
import cc.rengu.redp.bizimpl.upmp.vo.OperationResult;
import cc.rengu.redp.bizimpl.upmp.vo.UpmpUserInfoVO;
import cc.rengu.redp.bizimpl.utils.Common;
import cc.rengu.redp.bizimpl.utils.CommonUtils;
import cc.rengu.redp.bizimpl.utils.DateUtils;
import cc.rengu.redp.common.domain.QueryRequest;
import cc.rengu.redp.common.exception.RedpException;
import cc.rengu.redp.common.utils.SortUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.domain.PageImpl;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author 刘玉亮.LL
 */
@Slf4j
@Service
public class DirectMchntBaseInfoServiceImpl extends ServiceImpl<DirectMchntBaseInfoMapper, DirectMchntBaseInfo> implements IDirectMchntBaseInfoService {
    @Autowired
    private IUpmpSysParamService upmpSysParamService;

    @Autowired
    private IUpmpPrivilegeCheckService upmpPrivilegeCheckService;
    @Autowired
    private IUpmpOrganizationService organizationService;

    @Autowired
    private IUpmpBMchntBaseInfoService bMchntBaseInfoService;
    @Autowired
    @Qualifier("jdbcTemplate")
    private JdbcTemplate jdbcTemplate;

    @Autowired
    private IBizTmpService bizTmpService;
    @Autowired
    private IBizHisService bizHisService;
    
    @DubboReference(version = "${dubbo.protocol.version}", check = false)
    private BompMchntPublicDealService bompMchntPublicDealService;
    @Override
    public IPage<DirectMchntBaseInfo> findByPage(QueryRequest request, DirectMchntBaseInfo entity) {
        try {
            UpmpUserInfoVO user= CommonUtils.getCurrentUser(upmpSysParamService);
            LambdaQueryWrapper<DirectMchntBaseInfo> queryWrapper = new LambdaQueryWrapper<>();
            if (null != user && user.isAdmin()) {
                if(StringUtils.isBlank(entity.getInstId())){
                    queryWrapper.likeRight(DirectMchntBaseInfo::getInstId, entity.getInstId());
                }
            } else {
//            String crtOrgIds=user.getUserOrgCodes();
                String crtOrgIds="";
                queryWrapper.in(DirectMchntBaseInfo::getCrtOrgId,crtOrgIds);
            }
            if (StringUtils.isNotBlank(entity.getMchntCd())) {
                queryWrapper.likeRight(DirectMchntBaseInfo::getMchntCd, entity.getMchntCd());
            }
               if (StringUtils.isNotBlank(entity.getMchntCnNm())) {
                queryWrapper.likeRight(DirectMchntBaseInfo::getMchntCnNm, entity.getMchntCnNm());
            }
               if (StringUtils.isNotBlank(entity.getUnMchntCd())) {
                queryWrapper.likeRight(DirectMchntBaseInfo::getUnMchntCd, entity.getUnMchntCd());
            }
               if (StringUtils.isNotBlank(entity.getMchntStatus())) {
                queryWrapper.likeRight(DirectMchntBaseInfo::getMchntStatus, entity.getMchntStatus());
            }
               if (StringUtils.isNotBlank(entity.getAcqInsIdCd())) {
                queryWrapper.likeRight(DirectMchntBaseInfo::getAcqInsIdCd, entity.getAcqInsIdCd());
            }
            Page<DirectMchntBaseInfo> page = new Page<>();
            SortUtil.handlePageSort(request, page, true);
            return this.page(page, queryWrapper);
        } catch (Exception e) {
            log.error("分页查询失败", e);
            return null;
        }
    }
    @Override
    public DirectMchntBaseInfo getByMchntCd(String mchntCd) {
        LambdaQueryWrapper<DirectMchntBaseInfo> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(DirectMchntBaseInfo::getMchntCd,mchntCd);
        return this.getOne(queryWrapper);
    }

    /**
     * 查询直联商户导出数据
     *
     * @param request
     * @return
     * @throws RedpException
     */
    @Override
    public IPage<Map<String, Object>> findExportDataByPage(QueryRequest request, DirectMchntBaseInfo entity) throws RedpException {
        LambdaQueryWrapper<DirectMchntBaseInfo> queryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.isBlank(entity.getInstId())) {
            queryWrapper.eq(DirectMchntBaseInfo::getInstId, entity.getInstId());
        }else {
            UpmpUserInfoVO user= CommonUtils.getCurrentUser(upmpSysParamService);
            queryWrapper.eq(DirectMchntBaseInfo::getInstId, user.getInstId());
        }
        if (StringUtils.isNotBlank(entity.getMchntCd())) {
            queryWrapper.likeRight(DirectMchntBaseInfo::getMchntCd, entity.getMchntCd());
        }
        if (StringUtils.isNotBlank(entity.getMchntCnNm())) {
            queryWrapper.likeRight(DirectMchntBaseInfo::getMchntCnNm, entity.getMchntCnNm());
        }
        if (StringUtils.isNotBlank(entity.getMchntStatus())) {
            queryWrapper.likeRight(DirectMchntBaseInfo::getMchntStatus, entity.getMchntStatus());
        }
        if (StringUtils.isNotBlank(entity.getAcqInsIdCd())) {
            queryWrapper.likeRight(DirectMchntBaseInfo::getAcqInsIdCd, entity.getAcqInsIdCd());
        }
        Page<Map<String, Object>> page = new Page<>();
        SortUtil.handlePageSort(request, page, true);
        return this.baseMapper.findExportDataByPage(page, queryWrapper);
    }
    @Override
    @Transactional(value = "transactionManager")
    public OperationResult saveData(String oprMenuId, String oprMenuName, DirectMchntBaseInfo entity, String webNextUrl, String flag) throws RedpException {
        java.util.Map<String, Object> result = com.google.common.collect.Maps.newHashMap();
        String lastUpddt = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
        UpmpUserInfoVO user= CommonUtils.getCurrentUser(upmpSysParamService);
        UpmpOrganization org;
        //如果是管理员根据界面所选法人行查询总行机构
        if (user.isAdmin()) {
            org = organizationService.getHeadOrgByCode(entity.getInstId());
        } else {
            org = organizationService.getOrgByCode( user.getOrgCode(),user.getInstId());
        }
        if (PageOptFlagEnum.OPT_FLAG_ADD.getType().equals(flag)) {
            UpmpPrivilegeCheck privilegeCheck = upmpPrivilegeCheckService.getPrivilegeCheckByPrivilegeCode(user.getInstId(), "银联直连商户管理:新增");
            if ("00000000".equals(entity.getMchntCd())) {
                // 自动生成大商户号
                entity.setMchntCd(genCode(entity.getAcqRegionCd(), entity.getMchntTp(),entity.getInstId()));
                log.info("新增直联商户的商户编号为：" + entity.getMchntCd());
            }
            // 重复新增，变为修改操作
            if (StringUtils.isNotBlank(entity.getMchntCd())) {
                DirectMchntBaseInfo byMchntCd = getByMchntCd(entity.getMchntCd());
                if (null != byMchntCd) {
                    entity.setId(byMchntCd.getId());
                } else {
                    entity.setId(null);
                }
            } else {
                entity.setId(null);
            }
            //
            entity.setOprId(user.getId());
            entity.setCrtOrgId(org.getOrgCode());
            entity.setCreateTime(lastUpddt);
            entity.setLastOprId(user.getId());
            entity.setLastUpdateTime(lastUpddt);
            // 00-未报备 01-报备中 10-已系统报备 11-系统报备失败 20-已手工报备 21-手工报备失败
            entity.setCupsReportStatus("00");
            // 非正式  新增-待提交审批
            entity.setMchntStatus(BizDataStatusEnum.STATUS_DRAFT.getType());
            entity.setAuditStatus(BizDataAuditStatusEnum.AUDIT_STATUS_ADD_NOTCOMMIT.getType());
            // 入正式表
            this.save(entity);
            if (null != privilegeCheck && BusinessContainer.YES.equals(privilegeCheck.getChecked())) {
                bizTmpService.saveBizTmpDtl(entity, user, org.getInstId(), BizOprEnum.OPR_ADD.getType(), lastUpddt
                        , oprMenuId, oprMenuName, entity.getMchntStatus(), entity.getAuditStatus(), entity.getId(), webNextUrl, "N", "", entity.getMchntCd(), null, null);
            } else {
                // 录入历史表，状态改为 正式 新增-审核通过；
                DirectMchntBaseInfo DirectMchntBaseInfo = new DirectMchntBaseInfo();
                BeanUtils.copyProperties(entity, DirectMchntBaseInfo);
                DirectMchntBaseInfo.setMchntStatus(BizDataStatusEnum.STATUS_NORMAL.getType());
                DirectMchntBaseInfo.setAuditStatus(BizDataAuditStatusEnum.AUDIT_STATUS_ADD_PASS.getType());

                bizHisService.saveBizHisNew(DirectMchntBaseInfo, DirectMchntBaseInfo, user, org.getInstId(), BizOprEnum.OPR_ADD.getType(), lastUpddt
                        , oprMenuId, oprMenuName, entity.getId(), entity.getMchntCd(), null, null);
            }
            result.put("id", entity.getId());
            result.put("mchntCd", entity.getMchntCd());
        } else if (PageOptFlagEnum.OPT_FLAG_UPDATE.getType().equals(flag)) {
            // 上一次操作如果是新增-待提交审批的，前端传来upd标志，转到add方法处理
            DirectMchntBaseInfo lastDirectMchntBaseInfo = getByMchntCd(entity.getMchntCd());
            if (lastDirectMchntBaseInfo.getAuditStatus().equals(BizDataAuditStatusEnum.AUDIT_STATUS_ADD_NOTCOMMIT.getType())) {
                //
                return this.saveData(oprMenuId, oprMenuName, entity, webNextUrl, "add");
            }
            //
            String auditStatus = BizDataAuditStatusEnum.AUDIT_STATUS_UPD_NOTCOMMIT.getType();
            String id = entity.getId();
            if (Common.isBlank(id)) {
                log.error("请求参数(id)异常!");
                return OperationResult.buildFailureResult("请求参数(id)异常!", result);
            }

            UpmpPrivilegeCheck privilegeCheck = upmpPrivilegeCheckService.getPrivilegeCheckByPrivilegeCode(user.getInstId(), "银联直连商户管理:修改");
            DirectMchntBaseInfo dbDirectMchntBaseInfo = this.getById(id);
            DirectMchntBaseInfo DirectMchntBaseInfo = new DirectMchntBaseInfo();
            BeanUtils.copyProperties(entity, DirectMchntBaseInfo);

            entity.setLastOprId(user.getId());
            entity.setLastUpdateTime(lastUpddt);
            entity.setMchntStatus(dbDirectMchntBaseInfo.getMchntStatus());

            if (null != privilegeCheck && BusinessContainer.YES.equals(privilegeCheck.getChecked())) {
                dbDirectMchntBaseInfo.setLastOprId(user.getId());
                dbDirectMchntBaseInfo.setLastUpdateTime(lastUpddt);
                // 修改-待提交审批
                dbDirectMchntBaseInfo.setAuditStatus(auditStatus);

                this.updateById(dbDirectMchntBaseInfo);

                //检查临时表是否有数据，如果没用则新增
                entity.setAuditStatus(auditStatus);
                DirectMchntBaseInfo = new DirectMchntBaseInfo();
                BeanUtils.copyProperties(dbDirectMchntBaseInfo, DirectMchntBaseInfo);
                BeanUtils.copyProperties(entity, DirectMchntBaseInfo);

                bizTmpService.saveBizTmpDtl(DirectMchntBaseInfo, user, org.getInstId(), BizOprEnum.OPR_UPDATE.getType(), lastUpddt
                        , oprMenuId, oprMenuName, DirectMchntBaseInfo.getMchntStatus(), DirectMchntBaseInfo.getAuditStatus(), DirectMchntBaseInfo.getId(), webNextUrl, "N", "", DirectMchntBaseInfo.getMchntCd(), null, null);
                result.put("id", DirectMchntBaseInfo.getId());
            } else {
                // 修改-待提交审批
                entity.setAuditStatus(auditStatus);

                BeanUtils.copyProperties(entity, DirectMchntBaseInfo);
                this.updateById(DirectMchntBaseInfo);

                // 录入历史表，状态改为 正式 修改-审核通过；
                DirectMchntBaseInfo.setAuditStatus(BizDataAuditStatusEnum.AUDIT_STATUS_UPD_PASS.getType());
                //历史表新增
                bizHisService.saveBizHisNew(DirectMchntBaseInfo, dbDirectMchntBaseInfo, user, org.getInstId(), BizOprEnum.OPR_UPDATE.getType(), lastUpddt
                        , oprMenuId, oprMenuName, DirectMchntBaseInfo.getId(), DirectMchntBaseInfo.getMchntCd(), null, null);
            }
            result.put("id", entity.getId());
            result.put("mchntCd", entity.getMchntCd());
        } else if (PageOptFlagEnum.OPT_FLAG_STOP.getType().equals(flag)
                || PageOptFlagEnum.OPT_FLAG_USE.getType().equals(flag)
                || PageOptFlagEnum.OPT_FLAG_CANCEL.getType().equals(flag)) {
            String id = entity.getId();
            if (Common.isBlank(id)) {
                log.error("请求参数(id)异常!");
                return OperationResult.buildFailureResult("请求参数(id)异常!", result);
            }
            DirectMchntBaseInfo dbDirectMchntBaseInfo = this.getById(id);
            if (Common.isBlank(dbDirectMchntBaseInfo)) {
                log.error("根据id没有找到指定数据！");
                return OperationResult.buildFailureResult("根据id没有找到指定数据！", result);
            }
            DirectMchntBaseInfo DirectMchntBaseInfo = new DirectMchntBaseInfo();
            BeanUtils.copyProperties(dbDirectMchntBaseInfo, DirectMchntBaseInfo);

            UpmpPrivilegeCheck privilegeCheck = new UpmpPrivilegeCheck();
            String bizOpr = "";
            if (PageOptFlagEnum.OPT_FLAG_STOP.getType().equals(flag)) {
                bizOpr = BizOprEnum.OPR_STOP.getType();
                privilegeCheck = upmpPrivilegeCheckService.getPrivilegeCheckByPrivilegeCode(user.getInstId(), "银联直连商户管理:停用");
                if (null != privilegeCheck && BusinessContainer.YES.equals(privilegeCheck.getChecked())) {
                    // 停用-待提交审批
                    DirectMchntBaseInfo.setAuditStatus(BizDataAuditStatusEnum.AUDIT_STATUS_STOP_NOTCOMMIT.getType());
                } else {
                    // 停用-审核通过
                    DirectMchntBaseInfo.setAuditStatus(BizDataAuditStatusEnum.AUDIT_STATUS_STOP_PASS.getType());
                    DirectMchntBaseInfo.setMchntStatus(BizDataStatusEnum.STATUS_STOPED.getType());
                }
            } else if (PageOptFlagEnum.OPT_FLAG_USE.getType().equals(flag)) {
                bizOpr = BizOprEnum.OPR_USE.getType();
                privilegeCheck = upmpPrivilegeCheckService.getPrivilegeCheckByPrivilegeCode(user.getInstId(), "银联直连商户管理:启用");
                if (null != privilegeCheck && BusinessContainer.YES.equals(privilegeCheck.getChecked())) {
                    // 启用-待提交审批
                    DirectMchntBaseInfo.setAuditStatus(BizDataAuditStatusEnum.AUDIT_STATUS_USE_NOTCOMMIT.getType());
                } else {
                    // 启用-审核通过
                    DirectMchntBaseInfo.setAuditStatus(BizDataAuditStatusEnum.AUDIT_STATUS_USE_PASS.getType());
                    DirectMchntBaseInfo.setMchntStatus(BizDataStatusEnum.STATUS_NORMAL.getType());
                }
            } else if (PageOptFlagEnum.OPT_FLAG_CANCEL.getType().equals(flag)) {
                bizOpr = BizOprEnum.OPR_CANCEL.getType();
                privilegeCheck = upmpPrivilegeCheckService.getPrivilegeCheckByPrivilegeCode(user.getInstId(), "银联直连商户管理:注销");
                if (null != privilegeCheck && BusinessContainer.YES.equals(privilegeCheck.getChecked())) {
                    // 注销-待提交审批
                    DirectMchntBaseInfo.setAuditStatus(BizDataAuditStatusEnum.AUDIT_STATUS_CANCEL_NOTCOMMIT.getType());
                } else {
                    // 注销-审核通过
                    DirectMchntBaseInfo.setAuditStatus(BizDataAuditStatusEnum.AUDIT_STATUS_CANCEL_PASS.getType());
                    DirectMchntBaseInfo.setMchntStatus(BizDataStatusEnum.STATUS_CANCELED.getType());
                }
            }
            DirectMchntBaseInfo.setLastOprId(user.getId());
            DirectMchntBaseInfo.setLastUpdateTime(lastUpddt);
            this.updateById(DirectMchntBaseInfo);

            if (null != privilegeCheck && BusinessContainer.YES.equals(privilegeCheck.getChecked())) {
                //检查临时表是否有数据，如果没用则新增
                bizTmpService.saveBizTmpDtl(DirectMchntBaseInfo, user, org.getInstId(), bizOpr, lastUpddt
                        , oprMenuId, oprMenuName, DirectMchntBaseInfo.getMchntStatus(), DirectMchntBaseInfo.getAuditStatus(), DirectMchntBaseInfo.getId(), webNextUrl, "N", "", DirectMchntBaseInfo.getMchntCd(), null, null);
            } else {
                //历史表新增
                bizHisService.saveBizHisNew(DirectMchntBaseInfo, dbDirectMchntBaseInfo, user, org.getInstId(), bizOpr, lastUpddt
                        , oprMenuId, oprMenuName, DirectMchntBaseInfo.getId(), DirectMchntBaseInfo.getMchntCd(), null, null);
            }

            result.put("id", DirectMchntBaseInfo.getId());
            result.put("mchntCd", DirectMchntBaseInfo.getMchntCd());
        }

        result.put("formNm", "baseInfo");
        if(!PageOptFlagEnum.OPT_FLAG_ADD.getType().equals(flag)&&!PageOptFlagEnum.OPT_FLAG_UPDATE.getType().equals(flag)){
            return OperationResult.buildSuccessResult("", result);
        }else{
            return OperationResult.buildSuccessResult("数据保存处理完成", result);
        }
    }





    /**
     * 商户号，格式为: 收单行代码（3位） + 地区码（市级4位）+ 行业代码（4位）+ 序列号（4位）
     *
     * @return
     */
    private String genCode(String acqRegionCd, String mchntTp,String instId) throws RedpException {
        // 根据法人行获取银联收单机构号
        List<SysParamBean> igasParams = this.getIGASParams(BusinessContainer.MCMP_TO_BOMP_PARAM_TYPE, ParamQueryKeyEnum.UNION_PAY_ORG_CODE.getType(),instId);
        if (null == igasParams || igasParams.size() <= 0) {
            log.error("生成直联商户号失败");
            throw new RedpException("生成直联商户号失败");
        }
        String unionPayOrgCode = igasParams.get(0).getParamValue();
        if (unionPayOrgCode.length() < 4) {
            log.error("银联收单机构号长度有误");
            throw new RedpException("银联收单机构号长度有误");
        }
        // 前缀：收单行代码（3位） + 地区码（市级4位）+ 行业代码（4位）+ 序列号（4位）。
        String prefix = unionPayOrgCode.substring(1, 4) + acqRegionCd + mchntTp;
        // 生成序列号
        String nextVal = CommonUtils.getSequenceNext("BOMP_MCHNT_NO_SEQ", jdbcTemplate);
        return prefix + String.format("%04d", Integer.parseInt(nextVal));
    }
    /**
     * 根据法人行查询银联收单机构号
     *
     * @return List<SysParam>
     */
    public List<SysParamBean> getIGASParams(String paramType, String paramKey,String instId) throws RedpException {
        ParamQueryRequest reqDto = new ParamQueryRequest();
       UpmpUserInfoVO user =CommonUtils.getCurrentUser(upmpSysParamService);
//        //设置入参
        reqDto.setUserId(user.getId());
        reqDto.setParamType(paramType);
        reqDto.setParamKey(paramKey);

        //设置报文头
        String traceNo = bMchntBaseInfoService.genMerOrder(user.getInstId());
        reqDto.setHeader(CommonUtils.packageBompHeader(traceNo, BompTxnNumEnum.paramQuery.getType(), instId,null));

        Result<ParamQueryResponse> res = new Result<>();
        //TODO: 联调时放开
        try {
            log.info("生成直联商户号，获取银联收单机构号时接口请求报文:result=[{}]", JSON.toJSONString(reqDto));
            res = bompMchntPublicDealService.paramQuery(reqDto);
        } catch (Exception e) {
            log.error("生成直联商户号，获取银联收单机构号时系统异常:[{}]", e);
            throw new RedpException("生成直联商户号，获取银联收单机构号时系统异常,请联系管理员");
        }
        if (null == res || null == res.getResult()) {
            log.error("生成直联商户号，获取银联收单机构号时接口调用失败:result=[{}]", JSON.toJSONString(res));
            throw new RedpException("生成直联商户号，获取银联收单机构号时接口调用失败");
        }

        if (!BusinessContainer.BSPS_SUCCESS.equals(res.getResult().getRespCode())) {
            log.error("生成直联商户号，获取银联收单机构号时失败:code=[{}],msg=[{}]", res.getResult().getRespCode(), res.getResult().getRespDesc());
            throw new RedpException("生成直联商户号，获取银联收单机构号时失败:" + res.getResult().getRespDesc());
        }



        return res.getResult().getSysParamList();
    }
    @Override
    public List<ImageInfoVO> getmchntImageList(List<UpmpBMchntImageInfo> bMchntImageInfoList) {
        List<ImageInfoVO> mchntList = new ArrayList<>();
        for(UpmpBMchntImageInfo bmchntimageinfo:bMchntImageInfoList){
            ImageInfoVO imageinfovo=new ImageInfoVO();
            String name="";
            if (bmchntimageinfo.getImageType().equals("00")) {
                name = "经营执照";
            } else if (bmchntimageinfo.getImageType().equals("01")) {
                name = "法人证件照(人像面)";
            } else if (bmchntimageinfo.getImageType().equals("02")) {
                name = "法人证件照(国微面)";
            } else if (bmchntimageinfo.getImageType().equals("03")) {
                name = "签约协议照";
            } else if (bmchntimageinfo.getImageType().equals("04")) {
                name = "单位证明函照片";
            } else if (bmchntimageinfo.getImageType().equals("05")) {
                name = "资金管理关系证明照";
            } else if (bmchntimageinfo.getImageType().equals("06")) {
                name = "主流餐饮平台入驻证明照";
            } else if (bmchntimageinfo.getImageType().equals("07")) {
                name = "事业单位法人证书照";
            } else if (bmchntimageinfo.getImageType().equals("08")) {
                name = "办学资质照";
            } else if (bmchntimageinfo.getImageType().equals("09")) {
                name = "法人登记证书照";
            } else if (bmchntimageinfo.getImageType().equals("0A")) {
                name = "医疗执业许可证照";
            } else if (bmchntimageinfo.getImageType().equals("0B")) {
                name = "收费样本照";
            } else if (bmchntimageinfo.getImageType().equals("0C")) {
                name = "照会照";
            } else if (bmchntimageinfo.getImageType().equals("0D")) {
                name = "民办非企业单位登记证书";
            } else if (bmchntimageinfo.getImageType().equals("10")) {
                name = "商户门头照";
            } else if (bmchntimageinfo.getImageType().equals("11")) {
                name = "经营场所照";
            } else if (bmchntimageinfo.getImageType().equals("12")) {
                name = "手持证件照";
            } else if (bmchntimageinfo.getImageType().equals("20")) {
                name = "征信报告";
            } else if (bmchntimageinfo.getImageType().equals("21")) {
                name = "征信授权书";
            } else if (bmchntimageinfo.getImageType().equals("22")) {
                name = "联网核查报告";
            } else if (bmchntimageinfo.getImageType().equals("30")) {
                name = "结算账户照(商户结算净额)";
            } else if (bmchntimageinfo.getImageType().equals("31")) {
                name = "结算账户照(商户手续费)";
            } else if (bmchntimageinfo.getImageType().equals("40")) {
                name = "收款设备照";
            } else if (bmchntimageinfo.getImageType().equals("41")) {
                name = "交易凭证照";
            } else if (bmchntimageinfo.getImageType().equals("42")) {
                name = "现场服务工单";
            } else if (bmchntimageinfo.getImageType().equals("43")) {
                name = "商户培训确认表";
            } else if (bmchntimageinfo.getImageType().equals("44")) {
                name = "商户日常检查表";
            } else if (bmchntimageinfo.getImageType().equals("45")) {
                name = "现场培训签字表";
            } else if (bmchntimageinfo.getImageType().equals("99")) {
                name = "其它电子资料";
            }
            String imageLocalPath = bmchntimageinfo.getImageLocalPath();
            String fileSuffix = imageLocalPath.substring(imageLocalPath.lastIndexOf(".") + 1);
            imageinfovo.setName(name+bmchntimageinfo.getImageIndex()+"."+fileSuffix);
            imageinfovo.setImageType(bmchntimageinfo.getImageType());
            imageinfovo.setImageLocalPath(bmchntimageinfo.getImageLocalPath());
            imageinfovo.setId(bmchntimageinfo.getId());
            mchntList.add(imageinfovo);
        }
        return mchntList;
    }
}
